package com.uzai.console.web.wechatprivate;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceProductKeyEnum;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.common.utils.DateUtil;
import com.uzai.console.common.utils.Tools;
import com.uzai.console.dto.module.deviceproduct.DeviceProductQuery;
import com.uzai.console.dto.wechatprivate.configplan.ConfigPlanQuery;
import com.uzai.console.dto.devicegroup.DeviceGroupIdDto;
import com.uzai.console.dto.devicegroup.DeviceGroupInfoDto;
import com.uzai.console.dto.devicegroup.DeviceGroupQuery;
import com.uzai.console.dto.wechatprivate.devicewechatinfo.*;
import com.uzai.console.dto.user.usertypegroup.UserTypeGroupQuery;
import com.uzai.console.entity.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.mapper.*;
import com.uzai.console.service.devicegroup.DeviceGroupService;
import com.uzai.console.service.wechatprivate.DeviceWechatInfoService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.devicegroup.DeviceGroupInfoVo;
import com.uzai.console.vo.deviceproduct.DeviceProductVo;
import com.uzai.console.vo.user.wechatuser.WechatUserDeciceInfoVo;
import com.uzai.console.vo.wechatprivate.devicewechatinfo.*;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 个人微信机器人管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "个人微信机器人管理",tags = "个人微信|机器人管理")
@ApiSort(5)
@RestController
public class DeviceWechatInfoController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(DeviceWechatInfoController.class);

    @Autowired
    private DeviceWechatInfoService deviceWechatInfoService;
    @Autowired
    private SysRoleMapper sysRoleMapper;
    @Autowired
    private DeviceGroupService deviceGroupService;
    @Autowired
    private DeviceGroupMapper deviceGroupMapper;
    @Autowired
    private UserTypeGroupMapper userTypeGroupMapper;
    @Autowired
    private ConfigPlanMapper configPlanMapper;
    @Autowired
    private DevicePriceMapper devicePriceMapper;
    @Autowired
    private DeviceWechatInfoMapper deviceWechatInfoMapper;

    @ApiOperation(value = "分页查询机器人列表", notes = "分页查询机器人列表", response = DeviceWechatInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/deviceWechantInfo/findDeviceWechatInfoList")
    public Object findDeviceWechatInfoList(@RequestBody DeviceWechatInfoQuery deviceWechantInfoQuery){
        return deviceWechatInfoService.findDeviceWechatInfoList(deviceWechantInfoQuery);
    }

    @ApiOperation(value = "查询机器人信息", notes = "查询机器人信息", response = DeviceWechatInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/deviceWechantInfo/findDeviceWechatInfo")
    public Object findDeviceWechatInfoInfo(@RequestBody DeviceWechatInfoIdDto deviceWechantInfoIdDto){
        return deviceWechatInfoService.findDeviceWechatInfoInfo(deviceWechantInfoIdDto);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加机器人", notes = "添加机器人", response = DeviceWechatInfoAddVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/deviceWechantInfo/addDeviceWechatInfo")
    public Object addDeviceWechatInfo(@RequestBody DeviceWechatInfoAddDto deviceWechatInfoAddDto){
        deviceWechatInfoAddDto.setDeviceTypeId(1);
        return deviceWechatInfoService.addDeviceWechatInfo(deviceWechatInfoAddDto);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加机器人新版(只需要上传微信id)", notes = "添加机器人新版(只需要上传微信id)", response = DeviceWechatInfoAddVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/deviceWechantInfo/addDeviceWechatInfo_new")
    public Object addDeviceWechatInfo_new(@RequestBody DeviceWechatInfoAddDto_new deviceWechatInfoAddDto_new){
        deviceWechatInfoAddDto_new.setDeviceTypeId(1);
        deviceWechatInfoService.addDeviceWechatInfo_new(deviceWechatInfoAddDto_new);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑机器人信息", notes = "编辑机器人信息")
    @ApiOperationSupport(order = 3)
    @PostMapping("/deviceWechantInfo/updateDeviceWechatInfo")
    public Object updateDeviceWechatInfo(@RequestBody DeviceWechatInfoDto deviceWechantInfoDto){
        deviceWechatInfoService.updateDeviceWechatInfo(deviceWechantInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量修改机器人", notes = "批量修改机器人")
    @ApiOperationSupport(order = 3)
    @PostMapping("/deviceWechantInfo/batchUpdateDeviceWechatInfo")
    public Object batchUpdateDeviceWechatInfo(@RequestBody DeviceWechatInfoBatchDto deviceWechatInfoBatchDto){
        deviceWechatInfoService.batchUpdateDeviceWechatInfo(deviceWechatInfoBatchDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "批量删除机器人", notes = "批量删除机器人")
    @ApiOperationSupport(order = 4)
    @PostMapping("/deviceWechantInfo/delDeviceWechantInfo")
    public Object delDeviceWechantInfo(@RequestBody DeviceWechatInfoDelDto deviceWechatInfoDelDto){
        deviceWechatInfoDelDto.setDelStatus(1); //1表示已删除
        deviceWechatInfoDelDto.setUpdateTime(DateUtil.getNowTime());
        return deviceWechatInfoService.delDeviceWechatInfo(deviceWechatInfoDelDto);
    }

    @ApiOperation(value = "分页查询机器人分组列表", notes = "分页查询机器人分组列表", response = DeviceGroupInfoVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/deviceWechantInfo/findDeviceGroupList")
    public Object findDeviceGroupList(@RequestBody DeviceGroupQuery deviceGroupQuery){
        deviceGroupQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        return deviceGroupService.findDeviceGroupList(deviceGroupQuery);
    }

    @ApiOperation(value = "查询机器人分组详情", notes = "查询机器人分组详情", response = DeviceGroupInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/deviceWechantInfo/findDeviceGroupInfo")
    public Object findDeviceGroupInfo(@RequestBody DeviceGroupIdDto deviceGroupIdDto){
        return deviceGroupService.findDeviceGroupInfo(deviceGroupIdDto);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加机器人分组", notes = "添加机器人分组")
    @ApiOperationSupport(order = 7)
    @PostMapping("/deviceWechantInfo/addDeviceGroup")
    public Object addDeviceGroup(@RequestBody DeviceGroupInfoDto deviceGroupInfoDto){
        //添加个人微信机器人分组
        deviceGroupInfoDto.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        deviceGroupService.addDeviceGroup(deviceGroupInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑机器人分组", notes = "编辑机器人分组")
    @ApiOperationSupport(order = 8)
    @PostMapping("/deviceWechantInfo/updateDeviceGroup")
    public Object updateDeviceGroup(@RequestBody DeviceGroupInfoDto deviceGroupInfoDto){
        deviceGroupInfoDto.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        deviceGroupService.updateDeviceGroup(deviceGroupInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除机器人分组", notes = "删除机器人分组")
    @ApiOperationSupport(order = 9)
    @PostMapping("/deviceWechantInfo/deleteDeviceGroup")
    public Object deleteDeviceGroup(@RequestBody DeviceGroupIdDto deviceGroupIdDto){
        deviceGroupService.deleteDeviceGroup(deviceGroupIdDto);
        return true;
    }

    @ApiOperation(value = "查询机器人分组下拉选择框列表", notes = "查询机器人分组下拉选择框列表")
    @ApiOperationSupport(order = 10)
    @PostMapping("/deviceWechantInfo/findDeviceGroupSelect")
    public Object findDeviceGroupSelect(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();
        DeviceGroupQuery deviceGroupQuery = new DeviceGroupQuery();
        deviceGroupQuery.setMerId(getLoginInfo().getMerId());
        deviceGroupQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        List<DeviceGroup> deviceGroupList = deviceGroupMapper.findByList(deviceGroupQuery);
        if(deviceGroupList != null){
            for (DeviceGroup deviceGroup : deviceGroupList){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(String.valueOf(deviceGroup.getId()));
                selectKeyVo.setValue(deviceGroup.getName());
                selectIdVoList.add(selectKeyVo);
            }
        }
        return selectIdVoList;
    }

    @ApiOperation(value = "查询会员类型组下拉选择框列表", notes = "查询会员类型组下拉选择框列表")
    @ApiOperationSupport(order = 11)
    @PostMapping("/deviceWechantInfo/findUserTypeGroupSelect")
    public Object findUserTypeGroupSelect(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();
        UserTypeGroupQuery userTypeGroupQuery = new UserTypeGroupQuery();
        userTypeGroupQuery.setMerId(getLoginInfo().getMerId());
        List<UserTypeGroup> userTypeGroupList = userTypeGroupMapper.findByList(userTypeGroupQuery);
        if(userTypeGroupList != null){
            for (UserTypeGroup userTypeGroup : userTypeGroupList){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(String.valueOf(userTypeGroup.getId()));
                selectKeyVo.setValue(userTypeGroup.getName());
                selectIdVoList.add(selectKeyVo);
            }
        }
        return selectIdVoList;
    }

    @ApiOperation(value = "查询配置方案下拉选择框列表", notes = "查询配置方案下拉选择框列表")
    @ApiOperationSupport(order = 12)
    @PostMapping("/deviceWechantInfo/findConfigPlanSelect")
    public Object findConfigPlanSelect(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();
        ConfigPlanQuery configPlanQuery = new ConfigPlanQuery();
        configPlanQuery.setMerId(getLoginInfo().getMerId());
        configPlanQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        List<ConfigPlan> configPlanList = configPlanMapper.findByList(configPlanQuery);
        if(configPlanList != null){
            for (ConfigPlan configPlan : configPlanList){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(String.valueOf(configPlan.getId()));
                selectKeyVo.setValue(configPlan.getName());
                selectIdVoList.add(selectKeyVo);
            }
        }
        return selectIdVoList;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "更新PC端软件", notes = "更新PC端软件")
    @ApiOperationSupport(order = 13)
    @PostMapping("/deviceWechantInfo/updatePcClientSoft")
    public Object updatePcClientSoft(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.updatePcClientSoft(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量更新PC端软件", notes = "批量更新PC端软件")
    @ApiOperationSupport(order = 13)
    @PostMapping("/deviceWechantInfo/batchUpdatePcClientSoft")
    public Object batchUpdatePcClientSoft(@RequestBody DeviceWechatInfoIdListDto deviceWechatInfoIdListDto){
        deviceWechatInfoService.batchUpdatePcClientSoft(deviceWechatInfoIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.RESTART)
    @ApiOperation(value = "重启PC端软件", notes = "重启PC端软件")
    @ApiOperationSupport(order = 14)
    @PostMapping("/deviceWechantInfo/restartPcClientSoft")
    public Object restartPcClientSoft(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.restartPcClientSoft(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.RESTART)
    @ApiOperation(value = "批量重启PC端软件", notes = "批量重启PC端软件")
    @ApiOperationSupport(order = 14)
    @PostMapping("/deviceWechantInfo/batchRestartPcClientSoft")
    public Object batchRestartPcClientSoft(@RequestBody DeviceWechatInfoIdListDto deviceWechatInfoIdListDto){
        deviceWechatInfoService.batchRestartPcClientSoft(deviceWechatInfoIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.QUIT)
    @ApiOperation(value = "退出PC端软件", notes = "退出PC端软件")
    @ApiOperationSupport(order = 15)
    @PostMapping("/deviceWechantInfo/quitPcClientSoft")
    public Object quitPcClientSoft(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.quitPcClientSoft(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.QUIT)
    @ApiOperation(value = "批量退出PC端软件", notes = "批量退出PC端软件")
    @ApiOperationSupport(order = 15)
    @PostMapping("/deviceWechantInfo/batchQuitPcClientSoft")
    public Object batchQuitPcClientSoft(@RequestBody DeviceWechatInfoIdListDto deviceWechatInfoIdListDto){
        deviceWechatInfoService.batchQuitPcClientSoft(deviceWechatInfoIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.QUIT)
    @ApiOperation(value = "退出PC端微信", notes = "退出PC端微信")
    @ApiOperationSupport(order = 16)
    @PostMapping("/deviceWechantInfo/quitPcWechat")
    public Object quitPcWechat(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.quitPcWechat(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.QUIT)
    @ApiOperation(value = "批量退出PC端微信", notes = "批量退出PC端微信")
    @ApiOperationSupport(order = 16)
    @PostMapping("/deviceWechantInfo/batchQuitPcWechat")
    public Object batchQuitPcWechat(@RequestBody DeviceWechatInfoIdListDto deviceWechatInfoIdListDto){
        deviceWechatInfoService.batchQuitPcWechat(deviceWechatInfoIdListDto);
        return true;
    }

    @ApiOperation(value = "机器人价格查询", notes = "机器人价格查询", response = DeviceWechatInfoPriceVo.class)
    @ApiOperationSupport(order = 17)
    @PostMapping("/deviceWechantInfo/devicePrice")
    public Object devicePrice(@RequestBody DevicePriceDto devicePriceDto){
        return deviceWechatInfoService.getDevicePrice(devicePriceDto);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改机器人工作状态", notes = "修改机器人工作状态")
    @ApiOperationSupport(order = 18)
    @PostMapping("/deviceWechantInfo/updateRecvmsgType")
    public Object updateRecvmsgType(@RequestBody DeviceWechatRecvmsgTypeDto deviceWechatRecvmsgTypeDto){
        deviceWechatInfoService.updateRecvmsgType(deviceWechatRecvmsgTypeDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量修改机器人工作状态", notes = "批量修改机器人工作状态")
    @ApiOperationSupport(order = 18)
    @PostMapping("/deviceWechantInfo/updateRecvmsgType/batch")
    public Object batchUpdateRecvmsgType(@RequestBody DeviceWechatRecvmsgTypeBatchDto deviceWechatRecvmsgTypeBatchDto){
        deviceWechatInfoService.batchUpdateRecvmsgType(deviceWechatRecvmsgTypeBatchDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.BUY)
    @ApiOperation(value = "购买机器人授权", notes = "购买机器人授权", response = DeviceWechatInfoAddVo.class)
    @ApiOperationSupport(order = 19)
    @PostMapping("/deviceWechantInfo/buyDeviceAuth")
    public Object buyDeviceAuth(@RequestBody DeviceWechatInfoBuyAuthDto deviceWechatInfoBuyAuthDto){
        return deviceWechatInfoService.buyDeviceAuth(deviceWechatInfoBuyAuthDto);
    }

    @ApiOperation(value = "查询添加机器人和购买授权总金额", notes = "查询添加机器人和购买授权总金额", response = DeviceAmountVo.class)
    @ApiOperationSupport(order = 20)
    @PostMapping("/deviceWechantInfo/getAmount")
    public Object getAmount(@RequestBody DeviceAmountDto deviceAmountDto){
        return deviceWechatInfoService.getAmount(deviceAmountDto);
    }

    @ApiOperation(value = "查询设备功能类型列表", notes = "查询设备功能类型列表", response = DeviceProductVo.class)
    @ApiOperationSupport(order = 21)
    @PostMapping("/deviceWechantInfo/deviceProductList")
    public Object deviceProductList(){
        DeviceProductQuery deviceProductQuery = new DeviceProductQuery();
        deviceProductQuery.setStatus(1);
        return deviceWechatInfoService.deviceProductList(deviceProductQuery);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "封号名片转发", notes = "封号名片转发")
    @ApiOperationSupport(order = 22)
    @PostMapping("/deviceWechantInfo/banTranfer")
    public Object banTranfer(@RequestBody BanTransferDto banTransferDto){
        deviceWechatInfoService.banTranfer(banTransferDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "刷新手机卡密授权", notes = "刷新手机卡密授权")
    @ApiOperationSupport(order = 22)
    @PostMapping("/deviceWechantInfo/refreshMobileApp")
    public Object refreshMobileApp(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.refreshMobileApp(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "转移授权时间", notes = "转移授权时间")
    @ApiOperationSupport(order = 23)
    @PostMapping("/deviceWechantInfo/transferAuthTime")
    public Object transferAuthTime(@RequestBody TranferAuthTimeDto tranferAuthTimeDto){
        deviceWechatInfoService.transferAuthTime(tranferAuthTimeDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除单个机器人(是否转移数据)", notes = "删除单个机器人(是否转移数据)")
    @ApiOperationSupport(order = 24)
    @PostMapping("/deviceWechantInfo/delAndTransferData")
    public Object delAndTransferData(@RequestBody DelAndTransferDataDto delAndTransferDataDto){
        deviceWechatInfoService.delAndTransferData(delAndTransferDataDto);
        return true;
    }

    @ApiOperation(value = "查询同类型组的机器人下拉列表框列表（过滤自己和不是同类型组的机器人）", notes = "查询同类型组的机器人下拉列表框列表（过滤自己和不是同类型组的机器人）", response = WechatUserDeciceInfoVo.class)
    @ApiOperationSupport(order = 25)
    @PostMapping("/wechatuser/findSameGroupDeviceList")
    public Object findSameGroupDeviceList(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        List<WechatUserDeciceInfoVo> wechatUserDeciceInfoVoList = new ArrayList<>();
        if(deviceWechatInfoIdDto.getId() != null){
            DeviceWechatInfo deviceWechatInfo_self = deviceWechatInfoMapper.selectById(deviceWechatInfoIdDto.getId(), deviceWechatInfoIdDto.getMerId());
            if(deviceWechatInfo_self != null){
                ConfigPlan configPlan_self = configPlanMapper.selectById(deviceWechatInfo_self.getConfigId(), deviceWechatInfoIdDto.getMerId());
                if(configPlan_self != null){
                    Long userTypeGroupId_self = configPlan_self.getUserTypeGroupId();
                    if(userTypeGroupId_self != null){
                        DeviceWechatInfoQuery deviceWechatInfoQuery = new DeviceWechatInfoQuery();
                        deviceWechatInfoQuery.setMerId(getLoginInfo().getMerId());
                        List<DeviceWechatInfo> deviceWechatInfoList = deviceWechatInfoMapper.findByList(deviceWechatInfoQuery);
                        if(deviceWechatInfoList != null){
                            for (DeviceWechatInfo deviceWechatInfo : deviceWechatInfoList){
                                //过滤自己
                                if(deviceWechatInfoIdDto.getId().longValue() != deviceWechatInfo.getId().longValue()){
                                    ConfigPlan configPlan = configPlanMapper.selectById(deviceWechatInfo.getConfigId(), deviceWechatInfoIdDto.getMerId());
                                    //同一个会员类型组的机器人才能查询出来
                                    if(configPlan != null && Tools.getLong(configPlan.getUserTypeGroupId()).longValue() == userTypeGroupId_self.longValue()){
                                        WechatUserDeciceInfoVo wechatUserDeciceInfoVo = new WechatUserDeciceInfoVo();
                                        BeanUtils.copyProperties(deviceWechatInfo, wechatUserDeciceInfoVo);
                                        wechatUserDeciceInfoVoList.add(wechatUserDeciceInfoVo);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return wechatUserDeciceInfoVoList;
    }

    @ApiOperation(value = "查询机器人产品列表", notes = "查询机器人产品列表")
    @ApiOperationSupport(order = 25)
    @PostMapping("/deviceWechantInfo/findDeviceProductList")
    public Object findDeviceProductList(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();
        DeviceProductKeyEnum[] deviceProductKeyEnums = DeviceProductKeyEnum.values();
        if(deviceProductKeyEnums != null){
            for (DeviceProductKeyEnum deviceProductKeyEnum : deviceProductKeyEnums){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(deviceProductKeyEnum.getValue());
                selectKeyVo.setValue(deviceProductKeyEnum.getDesc());
                selectIdVoList.add(selectKeyVo);
            }
        }
        return selectIdVoList;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "刷新在线状态", notes = "刷新在线状态")
    @ApiOperationSupport(order = 26)
    @PostMapping("/deviceWechantInfo/refreshOnlineStatus")
    public Object refreshOnlineStatus(){
        deviceWechatInfoService.refreshOnlineStatus(getLoginInfo().getMerId());
        return true;
    }

    @ApiOperation(value = "查询所有个人微信机器人列表", notes = "查询所有个人微信机器人列表", response = DeviceWechatInfoVo.class)
    @ApiOperationSupport(order = 27)
    @PostMapping("/deviceWechantInfo/findDeviceWechatInfoSelect")
    public Object findDeviceWechatInfoSelect(@RequestBody DeviceWechatInfoQuery deviceWechantInfoQuery){
        return deviceWechatInfoService.findDeviceWechatInfoSelect(deviceWechantInfoQuery);
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "更新手机版", notes = "更新手机版")
    @ApiOperationSupport(order = 28)
    @PostMapping("/deviceWechantInfo/updateMobileClientSoft")
    public Object updateMobileClientSoft(@RequestBody DeviceWechatInfoIdDto deviceWechatInfoIdDto){
        deviceWechatInfoService.updateMobileClientSoft(deviceWechatInfoIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "批量更新手机版", notes = "批量更新手机版")
    @ApiOperationSupport(order = 29)
    @PostMapping("/deviceWechantInfo/batchUpdateMobileClientSoft")
    public Object batchUpdateMobileClientSoft(@RequestBody DeviceWechatInfoIdListDto deviceWechatInfoIdListDto){
        deviceWechatInfoService.batchUpdateMobileClientSoft(deviceWechatInfoIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.DeviceWechatInfo, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "增加试用期授权", notes = "增加试用期授权", response = Boolean.class)
    @ApiOperationSupport(order = 30)
    @PostMapping("/deviceWechantInfo/addProbationAuth")
    public Object addProbationAuth(@RequestBody DeviceWechatInfoAddProbationAuth deviceWechatInfoAddProbationAuth){
        deviceWechatInfoService.addProbationAuth(deviceWechatInfoAddProbationAuth);
        return true;
    }

    @ApiOperation(value = "手机号运营商查询", notes = "手机号运营商查询", response = MobiletypeFindVo.class)
    @ApiOperationSupport(order = 31)
    @PostMapping("/moble/findMobiletype")
    public Object findMobiletype(@RequestBody MobiletypeFindDto mobileTypeFindDto){
        return deviceWechatInfoService.findMobiletype(mobileTypeFindDto);
    }
}
